package com.comum.javahomework420242025.pojo;

import com.comum.javahomework420242025.utils.LocalDateTimeDeserializer;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.time.LocalDateTime;

@NoArgsConstructor
@AllArgsConstructor
@Data
@Entity
@Table(name = "chance")
public class Chance {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "chanceid")
    private Long chanceid;

    @Column(name = "chancename", length = 255)
    private String chancename;

    @Column(name = "projectname", length = 255)
    private String projectname;



    @Column(name = "phase", length = 255)
    private String phase;

    @Column(name = "areaname", length = 255)
    private String areaname;

    @Column(name = "budget", length = 255)
    private String budget;

    @Column(name = "areas", length = 255)
    private String areas;


    @Column(name = "chancedatetime")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") // 指定 JSON 输出的格式
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    private LocalDateTime chancedatetime;

    @Column(name = "comment", length = 255)
    private String comment;

    @Column(name = "keymen", length = 255)
    private String keymen;

    //客户id
    @Column(name = "clientcompanyid")
    private Long clientcompanyid;

    @Column(name = "stock", length = 255)
    private String stock;

    //员工id
    @Column(name = "clue")
    private Long clue;


    @ManyToOne
    @JoinColumn(name = "clue", insertable = false, updatable = false)
    private User user;

    @ManyToOne
    @JoinColumn(name = "clientcompanyid", insertable = false, updatable = false)
    private ClientCompany clientCompany;
}
